<?php

	$TPmain->Necho = 0;
	$bd = mktime();
	$d = $bd;

	$allpilots_r = mysql_query("select pilotid from finalpilots order by id");

    while ($pilot = mysql_fetch_assoc($allpilots_r))
    {

    	$pilot = $pilot[pilotid];

     	ob_start();

        $link = ConnectToBase ();

        echo "PARSING PILOT #$pilot<br>";

        echo "deleting all ships stat<br>";
        mysql_query("update finalpilots set cv='0', bb='0', ca='0', dd='0', ss='0' where pilotid='$pilot'");

        echo "Recalculate_Pilot_Rank...<br>";
		$rank = Recalculate_Pilot_Rank ($pilot);

        echo "Update_Pilot_Rank...<br>";
    	Update_Pilot_Rank ($pilot,$rank);

        echo "Update_Pilot_Common_Stat...<br>";
		UpdatePilotCommonStat ($pilot);

        echo "Recalculate_Pilot_Awards...<br>";
    	$awd = Recalculate_Pilot_Awards ($pilot);

        echo "Update_Pilot_Awards...<br>";
    	Update_Pilot_Awards ($pilot,$awd);

        echo "UpdateShipsForPilot...<br>";
        UpdateShipsForPilot($pilot);

		$d = mktime() - $d;
    	echo "$i. Done in ".$d."<br>";
        $d = mktime();


        ob_end_flush();

    }
	    $bd = mktime() - $bd;
    	echo $bd."<br>";

?>